-- ================================START====================================
-- Template generated from		FRAMEWORKIVY CODE GENERATOR
-- Generator Version:			<1.0.0.0>
-- Template Creation Time:		<Thursday, 26 May, 2016   12:32:16 AM>
-- Template Modification Time:	<Monday, 23 May, 2016   11:22:57 PM>
-- Code Generation Time:		<Thursday, 26 May, 2016   12:52:16 AM>
-- Workstation ID:				<PRAVESH>
-- Current system User ID:		<pravesh kr>
-- Entity/Table Name:			<Person>
-- Description:					<SQL Server Stored Procedure For Get All By Criteria>
-- Template File:				<IvyGodeGenDefaultTemplate V1.1.xml>

-- Please modify the generated code as per requirement.
-- This code generator is just to speed up the stereo type codes
-- Complex logic needs to be modified manually.

-- This block of comments will not be included in
-- the definition of the procedure.
-- =========================================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'Ivy_UserManagement_Person_GetAllByCriteria')
	BEGIN
		DROP  Procedure  [Ivy_UserManagement_Person_GetAllByCriteria]
	END
GO

CREATE PROCEDURE [Ivy_UserManagement_Person_GetAllByCriteria]
-- =========================================================================
-- Created by				FRAMEWORKIVY CODE GENERATOR
-- Generator Version:		<1.0.0.0>
-- Template version used:   <1.0>
-- Template created by:		<Mrinmoy Das>
-- Code generated by:		<pravesh kr>
-- Code generation Time:	<Thursday, 26 May, 2016   12:52:16 AM>
-- Entity/Table Name:		<Person>
-- Description:             <SQL Server Stored Procedure For Get All By Criteria>
-- =========================================================================

-- Add the parameters for the stored procedure here

	(
			@PersonKey int = NULL, 

			@PersonFirstName varchar(100) = NULL, 
			@PersonLastName varchar(100) = NULL, 
			@PersonSex char(1) = NULL, 
			@PersonDateOfBirth datetime = NULL, 
			@PersonPrimaryEmailID varchar(200) = NULL, 
			@PersonPrimaryEmailVerificationCode varchar(50) = NULL, 
			@PersonPrimaryEmailIsVerified bit = NULL, 
			@PersonAlternateEmailID varchar(200) = NULL, 
			@PersonPrimaryMobileNumber varchar(50) = NULL, 
			@PersonPrimaryMobileVerificationCode varchar(50) = NULL, 
			@PersonPrimaryMobileIsVerified bit = NULL, 
			@PersonAlternatePhoneNumber varchar(50) = NULL, 
			@PersonAddressLine1 varchar(300) = NULL, 
			@PersonAddressLine2 varchar(300) = NULL, 
			@PersonAddressCityName varchar(200) = NULL, 
			@PersonAddressStateName varchar(200) = NULL, 
			@PersonAddressCountryName varchar(200) = NULL, 
			@PersonAddressPinZipCode varchar(50) = NULL, 

			@Sys_ModifiedByID varchar(50) = NULL, 
			@Sys_DeleteType int = NULL, 
			@Sys_IsDeleted bit = NULL, 
			@Sys_OrganizationID int = NULL, 
			@Sys_InitialPrimaryKeys varchar(MAX) = NULL, 
			@Sys_WorkstationName varchar(50) = NULL 
	) 
AS 
BEGIN 
	-- SET NOCOUNT ON added to prevent extra result sets from interfering with SELECT statements. 
	SET NOCOUNT OFF; 

    SELECT 
			[PersonKey], 
			[PersonFirstName], 
			[PersonLastName], 
			[PersonSex], 
			[PersonDateOfBirth], 
			[PersonPrimaryEmailID], 
			[PersonPrimaryEmailVerificationCode], 
			[PersonPrimaryEmailIsVerified], 
			[PersonAlternateEmailID], 
			[PersonPrimaryMobileNumber], 
			[PersonPrimaryMobileVerificationCode], 
			[PersonPrimaryMobileIsVerified], 
			[PersonAlternatePhoneNumber], 
			[PersonAddressLine1], 
			[PersonAddressLine2], 
			[PersonAddressCityName], 
			[PersonAddressStateName], 
			[PersonAddressCountryName], 
			[PersonAddressPinZipCode], 

			[Sys_DateOfCreation], 
			[Sys_DateOfModification], 
			[Sys_CreatedByID], 
			[Sys_ModifiedByID], 
			[Sys_DeleteType], 
			[Sys_IsDeleted], 
			[Sys_OrganizationID], 
			[Sys_InitialPrimaryKeys], 
			[Sys_WorkstationName] 
    FROM 
			[Person] 
    WHERE 
		( 
			[PersonKey] = ISNULL(@PersonKey, [PersonKey]) AND 

			[PersonFirstName] = ISNULL(@PersonFirstName, [PersonFirstName]) AND 
			[PersonLastName] = ISNULL(@PersonLastName, [PersonLastName]) AND 
			[PersonSex] = ISNULL(@PersonSex, [PersonSex]) AND 
			[PersonDateOfBirth] = ISNULL(@PersonDateOfBirth, [PersonDateOfBirth]) AND 
			[PersonPrimaryEmailID] = ISNULL(@PersonPrimaryEmailID, [PersonPrimaryEmailID]) AND 
			[PersonPrimaryEmailVerificationCode] = ISNULL(@PersonPrimaryEmailVerificationCode, [PersonPrimaryEmailVerificationCode]) AND 
			[PersonPrimaryEmailIsVerified] = ISNULL(@PersonPrimaryEmailIsVerified, [PersonPrimaryEmailIsVerified]) AND 
			[PersonAlternateEmailID] = ISNULL(@PersonAlternateEmailID, [PersonAlternateEmailID]) AND 
			[PersonPrimaryMobileNumber] = ISNULL(@PersonPrimaryMobileNumber, [PersonPrimaryMobileNumber]) AND 
			[PersonPrimaryMobileVerificationCode] = ISNULL(@PersonPrimaryMobileVerificationCode, [PersonPrimaryMobileVerificationCode]) AND 
			[PersonPrimaryMobileIsVerified] = ISNULL(@PersonPrimaryMobileIsVerified, [PersonPrimaryMobileIsVerified]) AND 
			[PersonAlternatePhoneNumber] = ISNULL(@PersonAlternatePhoneNumber, [PersonAlternatePhoneNumber]) AND 
			[PersonAddressLine1] = ISNULL(@PersonAddressLine1, [PersonAddressLine1]) AND 
			[PersonAddressLine2] = ISNULL(@PersonAddressLine2, [PersonAddressLine2]) AND 
			[PersonAddressCityName] = ISNULL(@PersonAddressCityName, [PersonAddressCityName]) AND 
			[PersonAddressStateName] = ISNULL(@PersonAddressStateName, [PersonAddressStateName]) AND 
			[PersonAddressCountryName] = ISNULL(@PersonAddressCountryName, [PersonAddressCountryName]) AND 
			[PersonAddressPinZipCode] = ISNULL(@PersonAddressPinZipCode, [PersonAddressPinZipCode]) AND 

			[Sys_IsDeleted] = ISNULL(@Sys_IsDeleted, [Sys_IsDeleted]) AND
			[Sys_OrganizationID] = ISNULL(@Sys_OrganizationID, [Sys_OrganizationID]) 
		); 

END 
GO 

-- =================================END=====================================

